import os
import shutil
from glob import glob


check_imgs_path = '/home/nzd/check_imgs'
class1_map = {
    '0': f"{check_imgs_path}/level1",
    '1': f"{check_imgs_path}/upstairs",
    '2': f"{check_imgs_path}/downstairs",
}

class2_map = {
    '0': f"{check_imgs_path}/level2",
    '1': f"{check_imgs_path}/gravel",
    '2': f"{check_imgs_path}/lawn",
}

class_names = ['level1', 'upstairs', 'downstairs', 'level2', 'gravel', 'lawn']


if not os.path.exists(check_imgs_path):
    os.makedirs(check_imgs_path)
for p in class_names:
    os.makedirs(f"{check_imgs_path}/{p}")


img_files = glob("/home/nzd/save_imgs/*.jpg")
img_files.sort()
img_num = len(img_files)

for img in img_files:
    img_name = img.split('.')[0].split('/')[-1]
    print(img_name)
    
    year, month, day, hour, minute, second, milsec, c1, p1, c2, p2 = img_name.split('_')
    shutil.copy2(img, f"{class1_map[c1]}/{img_name}.jpg")
    shutil.copy2(img, f"{class2_map[c2]}/{img_name}.jpg")

